package com.chenju.javastatic.utils;

import com.chenju.javastatic.component.config.TargetProjectConfig;

import java.util.List;

public class EasyVisitUtils {

    public static boolean isVisitClass(String name) {
        List<String> packageStartsWithArray = TargetProjectConfig.getPackagesStringArray();
        List<String> ignorePackageNameArray = TargetProjectConfig.getIgnorePackagesStringArray();
        if (name.startsWith("BOOT-INF/classes")){
            name = name.substring(17);
        }
        String dotName = name.replace("/", ".");
        return packageStartsWithArray.stream().anyMatch(dotName::startsWith) && ignorePackageNameArray.stream().noneMatch(dotName::startsWith);
    }

    public static boolean isVisitMethod(String name) {
        return !("<clinit>".equals(name) || "<init>".equals(name));
    }
}
